package school.extra.base;

import school.domain.User;
import zhibi.commons.exception.MessageException;
import zhibi.frame.context.Constant;
import zhibi.frame.springmvc.base.AbstractController;

public abstract class BaseController extends AbstractController {



    /**
     * 登录的用户
     *
     * @return
     */
    protected User sessionUser() {
        return (User) session.getAttribute(Constant.SESSION.ADMIN);
    }

    protected void checkAdmin() {
        if (!sessionUser().getType().equals("admin")) throw new MessageException("普通用户没有权限");
    }


    protected String forward(String view, String tipMsg) {
        request.setAttribute("tipMsg", tipMsg);
        return view;
    }

}
